<template>
	<view class="teach-container">
		<view class="detail">
			<view class="course" v-for="(item, index) in tableData" :key="index" @click="open(item)">
				<view class="left">
					<image :src="item.imgUrl" mode="widthFix"></image>
				</view>
				<view class="center">
					<text class="name">{{item.activityName}}</text>
					<text>开始时间:{{parseTime(item.startTime,'{y}-{m}-{d} {h}:{i}')}}</text>
					<text>结束时间:{{parseTime(item.endTime,'{y}-{m}-{d} {h}:{i}')}}</text>
				</view>
				<view class="right">
					<text :class="item.status == 1?'green':''">{{ item.status == 1?'状态：已发布':'状态：未发布' }}</text>
				</view>
			</view>
		</view>
		<view >
			<button class="bottom-button" size="mini" @click="addCourse()">新增活动</button>
			<!-- <button size="mini" @click="addCate()">创建类目</button> -->
		</view>
		<uni-popup ref="popup" type="bottom">
			<view class="popup">
				<text @click="addExamination">添加试卷</text>
				<text @click="update">修改活动</text>
				<text  class="del">删除</text>
				<text class="cancel" @click="close">取消</text>
			</view>
		</uni-popup>
	</view>
</template>
<script>
	import { getAdminActivity} from '@/api/exam/activity.js'
	import {parseTime } from '@/utils/ruoyi'
	export default {
		data() {
			return {
				tableData: [],
				pageForm:{
					pageNo:1,
					pageSize:10,
				},
				parseTime,
			}
		},
		created() {
			this.getList();
		},
		methods: {
			open(e){
				this.active=e
				console.log(e)
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open('bottom')
			},
			close() {
				this.$refs.popup.close()
			},
			addCourse(){
				this.$tab.navigateTo('/pages/work/exam/addActivity')
			},
			getList(){
				getAdminActivity(this.pageForm).then(res=>{
					this.tableData=res.data.list
				})
			},
			update(){
				this.$tab.navigateTo('/pages/work/exam/addActivity?id='+this.active.id)
			},
			addExamination(){
				this.$tab.navigateTo('/pages/work/exam/examination?id='+this.active.id)
			}
		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page{
		background: #fff;
	}
	view {
		font-size: 14px;
		line-height: inherit;
	}
	
	/* #endif */
	.teach-container{
		background-color: #fff;
		padding: 40rpx;
		.detail {
			width: 100%;
			background-color: #fff;
			border-radius: 20rpx;
			padding-top: 20rpx;
			.course{
				display: flex;
				justify-content: space-around;
				border-bottom: 1px solid #EDEDED;
				padding: 10px 0;
				align-items: flex-end;
				text{
					line-height: 30px;
					font-size: 12px;
					font-family: Inter-Regular, Inter;
					font-weight: 400;
				}
				.left{
					width: 75px;
					height: 65px;
					overflow: hidden;
				}
				.center{
					width: 170px;
					padding-left: 10px;
					text{
						display: block;
						color: #508CFF;
					}
					.name{
						font-size: 14px;
						color: #000000;
					}
				}
				.right{
					color: #F26D6D;
					.green{
						color: #50B987;
					}
					
				}
			}
			
		}
		.bottom-button{
			color: #fff;
			width: 100px;
			height: 40px;
			font-size: 14px;
			line-height: 40px;
			background: #508CFF;
			border-radius: 5px 5px 5px 5px;
			position: absolute;
			bottom: 50px;
			left: 36%;
		}
		.popup{
			height: 207px;
			background: #FFFFFF;
			text{
				line-height: 50px;
				display: block;
				text-align: center;
				font-family: Roboto-Regular, Roboto;
				font-weight: 400;
				color: #000000;
				font-size: 16px;
			}
			.cancel{
				color: #F26D6D;
			}
		}
	}
</style>